<template>
  <div class="business-circles-container">
    <p
      class="legal-person-name"
      @click.prevent="handleBusinessRole(dataInfo.legalPersonName)"
    >
      <span>法定代表人</span>
      <span :class="{ 'page-link-color': dataInfo.legalPersonName }"
        >{{ dataInfo.legalPersonName | isEmptyData
        }}<em v-if="dataInfo.legalPersonName" class="iconfont icon-youjiantou"
      /></span>
    </p>
    <p v-for="(item, index) in list" :key="index">
      <span>{{ item.title }}</span>
      <span>{{ getValue(item) }}</span>
    </p>
  </div>
</template>

<script>
import { jumpPage, dateFormat, isEmptyData, provinceConversion } from "@/utils";
import { get as _get } from "lodash";

//是否是微小企业
const IS_MICRO_ENT = {
  0: "不是",
  1: "是",
};
export default {
  name: "BusinessCircles",
  props: {
    dataInfo: {
      type: Object,
    },
  },
  data() {
    return {
      list: [
        {
          title: "经营状态",
          field: "regStatus",
        },
        {
          title: "成立日期",
          field: "estiblishTime",
          isDate: true,
        },
        {
          title: "省",
          field: "base",
        },
        {
          title: "市",
          field: "city",
        },
        {
          title: "区",
          field: "district",
        },
        {
          title: "经营开始时间",
          field: "fromTime",
          isDate: true,
        },
        {
          title: "股票类型",
          field: "bondType",
        },
        {
          title: "企业联系方式",
          field: "phoneNumber",
        },
        {
          title: "股票号",
          field: "bondNum",
        },
        {
          title: "股票名",
          field: "bondName",
        },
        {
          title: "股票曾用名",
          field: "usedBondName",
        },
        {
          title: "注册资本",
          field: "regCapital",
        },
        {
          title: "注册资本币种",
          field: "regCapitalCurrency",
        },
        {
          title: "工商注册号",
          field: "regNumber",
        },
        {
          title: "实缴资本",
          field: "actualCapital",
        },
        {
          title: "实收注册资本币种",
          field: "actualCapitalCurrency",
        },
        {
          title: "企业评分",
          field: "percentileScore",
        },
        {
          title: "统一社会信用代码",
          field: "creditCode",
        },
        {
          title: "纳税人识别号",
          field: "taxNumber",
        },
        {
          title: "组织机构代码",
          field: "orgNumber",
        },
        {
          title: "营业期限",
          field: "toTime",
          isDate: true,
        },
        {
          title: "是否是微小企业",
          field: "isMicroEnt",
        },
        {
          title: "核准日期",
          field: "approvedTime",
          isDate: true,
        },
        {
          title: "企业类型",
          field: "companyOrgType",
        },
        {
          title: "行业",
          field: "industry",
        },
        {
          title: "人员规模",
          field: "staffNumRange",
        },
        {
          title: "国民经济行业分类中类",
          field: "industryAll.categoryMiddle",
        },
        {
          title: "国民经济行业分类大类",
          field: "industryAll.categoryBig",
        },
        {
          title: "国民经济行业分类门类",
          field: "industryAll.category",
        },
        {
          title: "国民经济行业分类小类",
          field: "industryAll.categorySmall",
        },
        {
          title: "参保人数",
          field: "socialStaffNum",
        },
        {
          title: "登记机关",
          field: "regInstitute",
        },
        {
          title: "曾用名",
          field: "historyNames",
        },
        {
          title: "英文名称",
          field: "property3",
        },
        {
          title: "注册地址",
          field: "regLocation",
        },
        {
          title: "经营范围",
          field: "businessScope",
        },
        {
          title: "企业标签",
          field: "tags",
        },
        {
          title: "吊销日期",
          field: "revokeDate",
          isDate: true,
        },
        {
          title: "吊销原因",
          field: "revokeReason",
        },
        {
          title: "注销日期",
          field: "cancelDate",
          isDate: true,
        },
        {
          title: "注销原因",
          field: "cancelReason",
        },
      ],
    };
  },
  methods: {
    /**
     * 进入商业角色页面
     * @param {*} humanName 人名
     */
    handleBusinessRole(humanName) {
      jumpPage(this, "BusinessRole", {
        companyName: this.$route.query.companyName,
        humanName,
      });
    },

    /**
     * 获取值
     * @param {*} isDate 是否需要格式化日期
     * @param {*} field 字段名称
     */
    getValue({ isDate, field }) {
      const value = _get(this.dataInfo, field);
      //是否需要格式化日期
      if (isDate) {
        return dateFormat(value);
      }
      if (field == "base") {
        //省份转换
        return provinceConversion(value);
      }
      if (field == "isMicroEnt") {
        //是否是微小企业
        return IS_MICRO_ENT[value];
      }
      return isEmptyData(value);
    },
  },
};
</script>